﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Plexer.ParallelPort;
using Plexer.PowerManagement;

namespace Plex_Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Test();
        }

        /// <summary>
        /// Sample code for controlling lights using Plexer/Parallel Port Multiplexer
        /// You can attach relay switches in your parallel port to control lights
        /// Using bitshift registers IC's, you can extend the output port from the available 8 outputs pins of the parallel port
        ///         
        ///  Plexer/Parallel Port Multiplexer will not work if you don't use bitshift ic. If you will use the entire/default 8 output pins of parallel port do not use this code.
        ///  
        /// Check this references regarding Parallel Port interfacing
        /// http://logix4u.net/parallel-port/15-a-tutorial-on-parallel-port-interfacing
        /// http://en.wikipedia.org/wiki/Parallel_port
        /// </summary>
        private static void Test()
        {
            ParallelPortInfo parallelport = new ParallelPortInfo();
            //Specify the Address Registers of your parallel port
            //usually the first parallel port (LPT1) data address starts on hex 0x378 or 888 or just check out the links above for more info
            parallelport.DataPortAddress = 888;
            parallelport.StatusPortAddress = 889;
            parallelport.ControlPortAdress = 890;

            parallelport.MC74HC95_Total = 2; //Specify how many bit shift IC's you used, if you will just want to use 8 outputs, specify 1
            parallelport.Pins = new List<PinInfo>();
            parallelport.DataPortPinAssigned = DataPortPinAssignment.Pin1; //specify which of the output pins of the parallel port you will use in the bit shift


            PowerManagement powermanagement = new PowerManagement(parallelport);

            //turn off all the switches
            powermanagement.TurnAllSwitch(SwitchingState.Off);

            //turn on all the switches
            powermanagement.TurnAllSwitch(SwitchingState.On);

            //turn on specific switch (do not execute first)
            powermanagement.TurnSpecificSwitch(10, SwitchingState.On);

            //turn on specific switch (execute after including the previous switch we turn on above)
            powermanagement.TurnSpecificSwitch(14, SwitchingState.On, true);
            
        }

    }
}
